Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 3 - Finder Commands / Command Definitions


Clean Up

A Clean Up command is a request to align objects in a window or on the desktop along the grid pattern selected in the Views control panel. The
View property for the window must be 0 ("by Small Icon") or 1 ("by Icon"). Depending on the parameters used with it, the Clean Up command can
have the same effect as choosing Clean Up Window, Clean Up Desktop, or Clean Up All from the Special menu.

SYNTAX
clean up [ all | ( referenceToObject [ by propertyLabel ] ) ]
PARAMETERS
referenceToObject
A reference to the desktop or to one or more container windows, or a reference to one or more elements of the desktop or a container window. If the reference is to the desktop or a container window, the command acts on the contents of the object. If the reference is to elements of the desktop or of a container window, the Finder aligns the specified objects to the nearest grid points and ignores the propertyLabel parameter.
Class: Reference or list of references
Default value: A reference to the desktop
propertyLabel
One of these property labels, specifying the order in which to clean up the objects: name, size, modification date, version, or comment. If you include the referenceToObject parameter and omit the propertyLabel parameter, the Finder aligns the objects to the nearest grid points without sorting them into a new arrangement. The command clean up all is equivalent to the command clean up desktop by name.
Class: Class identifier
Default value: None
RESULT
Reference to the specified object or list of references.

EXAMPLES
This script cleans up all of the Finder's open windows (not including the desktop) for which "by Icon" or "by Small Icon" is selected in the Views menu. The by name parameter specifies that the cleaned up icons are to be arranged in the windows by name.

tell application "Finder"   clean up windows by name
end tell
This script aligns the icons in the window for the disk My World to the nearest grid points without sorting them into a new arrangement:

tell application "Finder"   clean up window "My World"end tell
NOTES
The command clean up all is equivalent to the command clean up desktop by name and to the Clean Up All menu command (available when you select an item on the desktop, hold down the Option key, and pull down the Special menu). All these commands rearrange items on the desktop by name and place the Trash in its original position relative to the lower-right corner of the screen. However, if you use the Clean Up command without any parameters, the Finder aligns objects on the desktop to the nearest grid points without rearranging them.

If the referenceToObject parameter of the Clean Up command is a reference to one or more items in an open window or on the desktop, the command aligns their icons to the grid but ignores the propertyLabel parameter, if any. For example, this script aligns only the icon for the folder My Folder (not the contents of My Folder) to the grid:

tell application "Finder"   clean up folder "My Folder" of window "My World"end tell
However, if the window for a folder is open, you can use a script like this to clean up the contents of the window:

tell application "Finder"   clean up contents of folder "My Folder" of window of startup disk
end tell 

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996